home *** CD-ROM | disk | FTP | other *** search
Java Source | 2000-06-23 | 2.5 KB | 97 lines |
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
-
- public class AboutDialog extends Dialog
- {
- //DECLARE_CONTROLS
- //Insert "AboutDialog Declare Controls"
- Label label1;
- Button okButton;
-
- public AboutDialog(Frame parent, boolean modal)
- {
- super(parent, modal);
-
- //INIT_CONTROLS
-
- //Setting up the dialog the way we want it.
- //Insert "AboutDialog Dialog Setup"
- GridBagLayout gridBagLayout;
- gridBagLayout = new GridBagLayout();
- setLayout(gridBagLayout);
- setVisible(false);
- setSize(277,100);
- setBackground(new Color(15724527));
- setTitle("About...");
- setResizable(false);
-
- //Setting up label1 and placing it in the layout
- //Insert "AboutDialog label1 Setup"
- label1 = new Label("This is my cool SlideShow Application!",Label.CENTER);
- GridBagConstraints gbc;
- gbc = new GridBagConstraints();
- gbc.gridx = 1;
- gbc.gridy = 1;
- gbc.fill = GridBagConstraints.NONE;
- gbc.insets = new Insets(0,0,0,0);
- ((GridBagLayout)getLayout()).setConstraints(label1, gbc);
- add(label1);
-
- //Setting up okButton and placing it in the layout
- //Insert "AboutDialog okButton Setup"
- okButton = new Button();
- okButton.setLabel("OK");
- gbc = new GridBagConstraints();
- gbc.gridx = 1;
- gbc.gridy = 2;
- gbc.fill = GridBagConstraints.NONE;
- gbc.insets = new Insets(0,0,0,0);
- ((GridBagLayout)getLayout()).setConstraints(okButton, gbc);
- add(okButton);
-
- //REGISTER_LISTENERS
- //Registering our ActionListner with the okButton
- //Insert "AboutDialog Register Listeners"
- Action lAction = new Action();
- okButton.addActionListener(lAction);
- }
-
- /**
- * Shows or hides the component depending on the boolean flag b.
- * @param b if true, show the component; otherwise, hide the component.
- * @see java.awt.Component#isVisible
- */
- public void setVisible(boolean b)
- {
- //Place the dialog in the Macintosh Alert Position
- //Insert "AboutDialog setVisible"
- if(b)
- {
- Dimension bounds = Toolkit.getDefaultToolkit().getScreenSize();
- Dimension abounds = getSize();
-
- setLocation((bounds.width - abounds.width) / 2,
- (bounds.height - abounds.height) / 3);
- }
- super.setVisible(b);
- }
-
- //Innerclass for handling ActionEvents
- //Insert "AboutDialog ActionListener"
- class Action implements ActionListener
- {
- public void actionPerformed(ActionEvent event)
- {
- okButton_Clicked(event);
- }
- }
-
- //Respond to button clicked ActionEvents from the okButton
- //Insert "AboutDialog okButton_Clicked"
- void okButton_Clicked(ActionEvent event)
- {
- setVisible(false);
- }
- }
-